<?php

namespace Plugins\AdminBasic\Requests;

use App\Requests\AbstractRequest;
use Hyperf\Validation\Rule;
use Plugins\AdminBasic\Enums\BasicAdministratorsEnumStatus;


/**
 * 管理员验证器
 */
class BasicAdministratorsRequest extends AbstractRequest
{


    public function allRules(): array
    {
        return [
            'id'        => ['required'],
            'name'      => ['required'],
            'account'   => ['required', 'string', Rule::unique('basic_administrators', 'account')->whereNull('delete_time')->ignore($this->input('id'), 'id')],
            'password'  => ['required', 'string', 'between:6,20'],
            'role_ids'  => ['array'],
            'status'    => ['required', 'int', Rule::in(BasicAdministratorsEnumStatus::values())],
        ];
    }

    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'name' => '用户名',
            'account' => '账号',
            'password' => '密码',
            'error_number' => '密码错误次数',
            'lately_time' => '最近登录',
            'error_date' => '错误日期',
            'status' => '状态',
            'role_ids' => '角色',
            'create_id' => '创建人'
        ];
    }

    public function updateScene(): array
    {
        return ['id', 'name', 'account', 'status',];
    }

    public function storeScene(): array
    {
        return ['name', 'account', 'password', 'status',];
    }

    public function destroyScene(): array
    {
        return [
            'data' => 'array'
        ];
    }
}